1. create a ByteBuffer from a byte array
byte[] bytes = new byte[10];2. retrieve bytes between the position and limit
ByteBuffer buffer = ByteBuffer.wrap(bytes);
bytes = new byte[buffer.remaining()];3. retrieve all bytes in the buffer
buffer.get(bytes, 0, bytes.length);
buffer.clear();
bytes = new byte[buffer.capacity()];
buffer.get(bytes, 0, bytes.length);
'java' 카테고리의 다른 글
| 클래스 패스 및 파일 확인하는 코드 (0) | 2008/06/16 |
|---|---|
| 파일에 락 걸기.. (0) | 2008/06/13 |
| Convert interchangeably between a ByteBuffer and a byte array (0) | 2008/06/13 |
| debugging을 위한 class line 보기 (0) | 2008/06/13 |
| Java SE의 정규 표현식 (0) | 2008/06/12 |